<?php
// extract ($data);

// $articles = count($data['Article']);
// $this->Tree->addItemAttribute('class', 'item'); // highlight this li
// if($articles == (int) 1 && isset($data['Article'][0]['slug']) ){ // 
// 	$url = ($Menus['slug'] != '/' && $Menus['slug'] != "") ? array('plugin'=>false,'controller'=>false,'action'=>$Menus['slug']) : $Menus['slug'];
// }else{
// 	$url = ($Menus['slug'] != '/' && $Menus['slug'] != "") ? array('plugin'=>false,'controller'=>false,'action'=>$Menus['slug']) : $Menus['slug'];
// }
// echo $this->Html->link($Menus['name'], $this->Html->url($url,true),array('title'=>$Menus['title']));




extract ($data);
$articles = count($data['Article']);
$this->Tree->addItemAttribute('class', 'item'); // highlight this li
if(isset($Menus['url']) && !empty($Menus['url'])){
	$url = $Menus['url'];
}else{
	if($articles === 1 && isset($data['Article']['slug'])){ //
		$url = '/a/'.$data['Article']['slug'];	
	}else{	
		$url = ($Menus['slug'] != '/' && $Menus['slug'] != "") ? array('plugin'=>false,'controller'=>false,'action'=>$Menus['slug']) : $Menus['slug'];
	}
}

if(!is_array($url)){
	$external = (preg_match("/http/i", $url));
}else{
	$external = false;
}
$url = ($external) ? $url : $this->Html->url($url,true);

echo $this->Html->link(Sanitize::html($Menus['name'], array('remove' => true)),$url ,array('title'=>$Menus['title'],'class'=>$Menus['css_class'],'escape'=>false));
